<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
</head>
<a href="/user">个人页面</a>
<a href="/houseInfo">房屋总览</a>
<a href="/sendHouse">我要卖房</a>
<a href="/about">关于我们</a>
<a href="/exit">退出</a>
<body>
<h1>个人信息</h1>
<table border="1">
    <tr>
        <td>用户id</td>
        <td>{{.Id}}</td>
    </tr>
    <tr>
        <td>用户名</td>
        <td>{{.Name}}</td>
    </tr>
    <tr>
        <td>用户邮箱</td>
        <td>{{.Mail}}</td>
    </tr>
    <tr>
        <td>微信</td>
        <td>{{.Wechat}}</td>
    </tr>
    <tr>
        <td>手机号</td>
        <td>{{.PhoneNum}}</td>
    </tr>

</table>

<form method="post" action="/user">
    <input type="submit" value="修改个人信息">
</form>

<h1>我的房子</h1>
<table border="1">
    <tr>
        <td>Id</td>
        <td>房屋面积</td>
        <td>房屋价格</td>
        <td>房屋朝向</td>
        <td>房屋楼层</td>
        <td>房屋年龄</td>
        <td>出售紧急程度</td>
    </tr>
    {{range $i,$v := .arr}}
    <tr>
        {{range $k,$w := $v}}
        <td>{{$w}}</td>
        {{end}}
        <td>
            <button><a href="/detail/?id={{index $v 0}}">详情</a></button>
        </td>
        <td>
            <button class="deleteHouse" type="button" value="{{index $v 0}}">删除</button>
        </td>
    </tr>
    {{end}}
</table>
<!--<table border="1">-->
<!--    {{range $i,$v := .Houses}}-->
<!--    <tr>-->
<!--        <td>我的第{{$i}}个房子</td>-->
<!--        <td>-->
<!--            <button type="button"><a href="/detail/?id={{$v}}">详情</a></button>-->
<!--        </td>-->
<!--        <td>-->
<!--            <button type="button" id="deleteHouse{{$i}}" value="{{$v}}" class="deleteHouse">删除</button>-->
<!--        </td>-->
<!--    </tr>-->
<!--    {{end}}-->
<!--</table>-->
</body>
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
    $(document).ready(function () {
        $(".deleteHouse").on("click", function (e) {
            let id = $(this).attr("value")
            console.log("id is: ", id)
            let data = {
                "type": "deleteHouse",
                "houseId": id
            };
            $.ajax({
                url: "/user",
                type: "POST",
                data: JSON.stringify(data),
                contentType: "application/json",
                dataType: "json",
            });
        });
    })
</script>
</html>